<template>
	<view class="onnext">
		<view class="onnext-item" v-for="(item,index) in find" :key="item.id">
			<view class="time">中国大陆上映</view>
			<swiper class="swiper" indicator-dots @click="goDetail(item.id)">
				<swiper-item v-for="(item,index) in item.pics" :key="index">
					<view class="swiper-item">
						<image :src="item.img_url" mode="aspectFill"></image>
					</view>
				</swiper-item>
			</swiper>
			<view class="text">
				<view class="text-top">
					<image class="cover" :src="item.cover_url" mode="aspectFill" @click="goDetail(item.id)"></image>
					<!-- <view class="t-tit">
						<view class="like">
							<uni-icons :type="flag[index]?'heart-filled':'heart'" size="30px" color="#ff9500" @click="collect(index)"></uni-icons>
							<view style="color: #ff9500;">想看</view>
						</view>
					</view> -->
					<view class="t-text">
						<view class="b">{{ item.title }}</view>
						<view>尚未上映</view>
						<view>{{ item.tag }}</view>
					</view>
				</view>
				<rich-text class="brief" :nodes="item.intro"></rich-text>
			</view>
		</view>
		<!-- 底部区域 -->
		<view class="bottom" v-show="findflag">前面的区域以后再来探索吧</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pageIndex: 0,
				findflag: false,
				flag: [],
				find: []
			}
		},
		onLoad() {
			this.getOnNext()
		},
		onReachBottom() {
			// console.log('触底了')
			this.pageIndex++
			this.getOnNext()
		},
		methods: {
			getOnNext() {
				uni.request({
					url: 'http://www.yingke.com/Index/movieType?type=4&page='+this.pageIndex,
					method: 'POST',
					success: (res) => {
							if(res.data.data.length==0){
								this.findflag = true
							}
							else{
								this.find = [...this.find,...res.data.data]
							}
					}
				})
			},
			goDetail(id){
				uni.navigateTo({
					url: '../mov-detail/mov-detail?data='+id
				})
			},
			collect(index) {
				if(this.flag[index]){
					this.flag[index] = 0
					//收藏表中删除该项
				}
				else{
					this.flag[index] = 1
					//收藏表中增加该项
				}
				// console.log(this.flag)
				this.$forceUpdate()
				//将对应id的影片加入收藏数组
			}
		}
	}
</script>

<style lang="scss">
	.onnext{
		margin: 10px 10px;
		.onnext-item{
			padding-bottom: 10px;
			border-bottom: 1px solid #eaeaea;
			.time{
				margin: 10px 10px;
			}
			.swiper{
				width: 355px;
				height: 230px;
				border-radius: 10px;
				image{
					width: 355px;
					height: 230px;
					border-radius: 10px;
				}
			}
			.text{
				margin-top: 10px;
				.text-top{
					display: flex;
					line-height: 25px;
					.cover{
						width: 90px;
						height: 130px;
						border-radius: 10px;
					}
					.t-tit{
						margin-top: 5px;
						margin-right: 10px;
						.like{
							position: absolute;
							right: 10px;
							text-align: center;
						}
					}
				}
				.brief{
					margin-top: 10px;
				}
			}
		}
		.bottom{
			height: 50px;
			margin-top: 20px;
			text-align: center;
		}
	}
</style>
